using System;
using NUnit.Framework;
using DotNetXmlSwfChart;

namespace DotNetXmlSwfChart.UnitTest
{
    [TestFixture]
    public class ChartPreferencesFixture
    {
        [Test]
        public void LineToSourceXml()
        {
            string testXml =
                "<chart_pref line_thickness='1' " +
                            "point_shape='circle' " + 
                            "fill_shape='True' " +
                            "/>";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.Line);
            cp.LineThickness = 1;
            cp.PointShape = "circle";
            cp.FillShape = true;
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }

        [Test]
        public void BarToSourceXml()
        {
            string testXml = "<chart_pref reverse='True' />";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.Bar);
            cp.Reverse = true;
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }

        [Test]
        public void BarFloatingToSourceXml()
        {
            string testXml = "<chart_pref reverse='True' />";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.BarFloating);
            cp.Reverse = true;
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }

        [Test]
        public void BarStackedToSourceXml()
        {
            string testXml = "<chart_pref reverse='True' />";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.BarStacked);
            cp.Reverse = true;
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }

        [Test]
        public void CandlestickToSourceXml()
        {
            string testXml = 
                "<chart_pref type='body' " +
                            "line_thickness='2' " +
                            "bull_color='ffffff' " +
                            "bear_color='000000' " +
                            "/>";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.Candlestick);
            cp.Type = "body";
            cp.LineThickness = 2;
            cp.BullColor = "ffffff";
            cp.BearColor = "000000";
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }

        [Test]
        public void ScatterToSourceXml()
        {
            string testXml =
                "<chart_pref point_size='2' " +
                            "point_shape='circle' " +
                            "trend_thickness='3' " +
                            "trend_alpha='1' " +
                            "line_thickness='2' " +
                            "line_alpha='1' " +
                            "/>";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.Scatter);
            cp.PointSize = 2;
            cp.PointShape = "circle";
            cp.TrendThickness = 3;
            cp.TrendAlpha = 1;
            cp.LineThickness = 2;
            cp.LineAlpha = 1;
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }

        [Test]
        public void Column3dToSourceXml()
        {
            string testXml =
                "<chart_pref rotation_x='20' " +
                            "rotation_y='40' " +
                            "/>";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.Column3d);
            cp.RotationX = 20;
            cp.RotationY = 40;
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }

        [Test]
        public void ColumnParallel3dToSourceXml()
        {
            string testXml =
                "<chart_pref rotation_x='20' " +
                            "rotation_y='40' " +
                            "/>";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.ColumnParallel3d);
            cp.RotationX = 20;
            cp.RotationY = 40;
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }

        [Test]
        public void ColumnStacked3dToSourceXml()
        {
            string testXml =
                "<chart_pref rotation_x='20' " +
                            "rotation_y='40' " +
                            "/>";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.ColumnStacked3d);
            cp.RotationX = 20;
            cp.RotationY = 40;
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }

        [Test]
        public void PolarToSourceXml()
        {
            string testXml =
                "<chart_pref type='line' " +
                            "grid='linear' " +
                            "line_thickness='1' " +
                            "point_shape='circle' " +
                            "point_size='6' " +
                            "fill_shape='False' " +
                            "/>";
            ChartPreferences cp = new ChartPreferences(XmlSwfChartType.Polar);
            cp.Type = "line";
            cp.Grid = "linear";
            cp.LineThickness = 1;
            cp.PointShape = "circle";
            cp.PointSize = 6;
            cp.FillShape = false;
            Assert.AreEqual(testXml, cp.ToSourceXML());
        }
    }
}
